/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.tracking.navegacion_core.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;

/**
 *
 * @author cacha
 */

public class Business {
    
    private ArrayList<DeliveryMan> deliveryManArrayList;
    private ArrayList<Order> orderList;
    private StrategyPath strategy;
    private String cuit;
    private String address;
    private String name;
    private Map objectsMap;

    /**
     * @return the deliveryManArrayList
     */
    private ArrayList<DeliveryMan> getDeliveryManArrayList() {
        return deliveryManArrayList;
    }

    /**
     * @param deliveryManArrayList the deliveryManArrayList to set
     */
    private void setDeliveryManArrayList(ArrayList<DeliveryMan> deliveryManArrayList) {
        this.deliveryManArrayList = deliveryManArrayList;
    }

    /**
     * @return the orderList
     */
    private ArrayList<Order> getOrderList() {
        return orderList;
    }

    /**
     * @param orderList the orderList to set
     */
    private void setOrderList(ArrayList<Order> orderList) {
        this.orderList = orderList;
    }
    
    /**
     * @return the deliveryMan required, or null if not exist
     */
    private DeliveryMan getDeliveryMan(String nickname) {
        DeliveryMan resultDeliveryMan = null;
        Boolean deliveryManFound = false;
        
        Iterator<DeliveryMan> deliveryManIterator = this.getDeliveryManArrayList().iterator();
        while( deliveryManIterator.hasNext() && !deliveryManFound){
            DeliveryMan currentDeliveryMan = deliveryManIterator.next();
            if(currentDeliveryMan.getNickName().equalsIgnoreCase(nickname)){
                deliveryManFound = true;
                resultDeliveryMan = currentDeliveryMan;
            }
        }
        
        return resultDeliveryMan ;
    }

    /**
     * @param deliveryMan the deliveryMan to set
     */
    private void addDeliveryMan(DeliveryMan deliveryMan) {
        this.getDeliveryManArrayList().add(deliveryMan); 
    }

    /**
     * @return the result of the opereration
     */
    private Boolean removeDeliveryMan(String nickname) {
        Boolean resultDeliveryMan = false;
        Boolean deliveryManFound = false;
        
        Iterator<DeliveryMan> deliveryManIterator = this.getDeliveryManArrayList().iterator();
        while( deliveryManIterator.hasNext() && !deliveryManFound){
            DeliveryMan currentDeliveryMan = deliveryManIterator.next();
            if(currentDeliveryMan.getNickName().equalsIgnoreCase(nickname)){
                deliveryManFound = true;
                resultDeliveryMan = currentDeliveryMan.removeBusiness(this.getName());
            }
        }
        
        return resultDeliveryMan;                
    }    
    
    /**
     * @return the order required, or null if noy exist
     */
    private Order getOrder(String serial) {
        Order resultOrder = null;
        Boolean orderFound = false; 
        
        Iterator<Order> orderIterator = this.getOrderList().iterator();
        while(orderIterator.hasNext() && !orderFound){
            Order currentOrder = orderIterator.next();
            If(currentOrder.getSerial().equalsIgnoreCase(serial)){
                resultOrder = currentOrder;
                orderFound = true;
            }                         
        }
        
        return resultOrder;
    }

    /**
     * @param order the order to set
     */
    private void addOrderList(Order order) {
        this.getOrderList().add(order); 
    }   

    /**
     * @return the order required, or null if noy exist
     */
    
    /*
     
    FALTA IMPLEMENTAR!! 
     
     
    private Boolean removeOrder(String serial) {
        Order resultOrder = null;
        Boolean orderFound = false; 
        
        Iterator<Order> orderIterator = this.getOrderList().iterator();
        while(orderIterator.hasNext() && !orderFound){
            Order currentOrder = orderIterator.next();
            If(currentOrder.getSerial().equalsIgnoreCase(serial)){
                resultOrder = currentOrder;
                orderFound = true;
            }                         
        }
        
        return orderFound;
    }    
    */
    
    /**
     * @return the strategy
     */
    public StrategyPath getStrategy() {
        return strategy;
    }

    /**
     * @param strategy the strategy to set
     */
    public void setStrategy(StrategyPath strategy) {
        this.strategy = strategy;
    }

    /**
     * @return the cuit
     */
    public String getCuit() {
        return cuit;
    }

    /**
     * @param cuit the cuit to set
     */
    public void setCuit(String cuit) {
        this.cuit = cuit;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the objectsMap
     */
    public Map getObjectsMap() {
        return objectsMap;
    }

    /**
     * @param objectsMap the objectsMap to set
     */
    public void setObjectsMap(Map objectsMap) {
        this.objectsMap = objectsMap;
    }
    
    public void asociateDeliveryMan(DeliveryMan deliveryMan){
        this.addDeliveryMan(deliveryMan);
    };
    
    public void unasociateDeliveryMan(){};
    
    public void asociateDeliveryToDeliveryMan(){};
    
    public void unasociateDeliveryToDeliveryMan(){};
    
    public void asociateOrderToDelivery(){};
    
    public void unasociateOrderToDelivery(){};
    
    public void cancelOrder(){};
    
    public void setFastestPath(){};
        
    public void setShortestPath(){};
    
    public void suspendOrder(){};
    
}
